"""商城登录的首页"""
from selenium.webdriver.common.by import By

from page_objects.base_page import BasePage


class LoginPage(BasePage):
    _BASE_URL = "https://litemall.hogwarts.ceshiren.com/#/login"
    __INPUT_USERMANE = (By.NAME, "username")
    __INPUT_PASSWORD = (By.NAME, "password")
    __CLICK_DENGLU = (By.CSS_SELECTOR, ".el-button")

    def login(self):
        # 访问登录页面
        # 输入”用户名“
        # self.driver.find_element(By.CSS_SELECTOR, '[name="username"]').clear()
        # self.driver.find_element(By.CSS_SELECTOR, '[name="username"]').send_keys("hogwarts")
        self.do_send_key("hogwarts", self.__INPUT_USERMANE)

        # 输入密码
        # self.driver.find_element(By.CSS_SELECTOR, '[name="password"]').clear()
        # self.driver.find_element(By.CSS_SELECTOR, '[name="password"]').send_keys("test12345")
        self.do_send_key("test12345", self.__INPUT_PASSWORD)
        # 点击登录
        # self.driver.find_element(By.CSS_SELECTOR, ".el-button").click()
        self.do_find(self.__CLICK_DENGLU).click()

        #  ===》进入首页
        from page_objects.home_page import HomePage
        return HomePage(self.driver)
